package com.chuanyang.driverh.utils;

import android.app.Activity;
import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.chuanyang.driverh.R;


/**
 * Log Toast 工具类
 * @author joyskim
 *
 */
public class PrintUtil {
	

	
	public static void toast(Context context,String content){
		if (context==null)return;
		if (StringUtil.isBlank(content))return;
		if (context instanceof Activity) {
			makeToast(context, content, Toast.LENGTH_SHORT);
		}else{
			Toast.makeText(context,content,Toast.LENGTH_SHORT).show();
		}
	}

	private static void makeToast(Context context,String content,int during){
		Toast toast = new Toast(context);
		toast.setDuration(during);
		View view = View.inflate(context, R.layout.toast_custom,null);
		TextView tvPrompt = (TextView)view.findViewById(R.id.tv_prompt);
		tvPrompt.setWidth(ActivityUtil.getScreenWidthMetrics((Activity) context));
		tvPrompt.setHeight(ActivityUtil.getScreenWidthMetrics((Activity) context)/2);
		tvPrompt.setText(content);
		toast.setView(view);
		toast.setGravity(Gravity.CENTER, 0, 0);
		toast.show();

	}
	
	public static void toastLong(Context context,String content){
		makeToast(context,content,Toast.LENGTH_LONG);
	}




	
}
